<?php
/*
Mooha Server - SyncML Server written in PHP (http://mooha.net)
Copyright (C) 2009	Artem Bandur <artico.bandurini@gmail.com>
					Madcap BV (http://www.madcap.nl)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA	02110-1301, USA.
*/

class SyncmlException extends Exception {
	private $previous = NULL;
	
	function __construct($message = "", $code = 0, $previous = NULL) {
		if (method_exists('Exception', 'getPrevious')) {
			parent::__construct($message, $code, $previous);
		}
		else {
			parent::__construct($message, $code);
			$this->previous = $previous;
		}
	}
	
	// implement method Exception->getPrevious in PHP prior to 5.3.0
	function __call($name, $arguments) {
		if ($name == 'getPrevious') {
			return $this->previous;
		}
	}	
}

/*

SyncmlException codes

100 - cannot run Mysql
101 - cannot run WbxmlHelper
102 - cannot run WbxmlDecoderPhp
103 - cannot run WbxmlEncoderPhp
105 - request is non-syncml
106 - request is unreadable
107 - request is empty
108 - mysql query error

110 - cannot decode
111 - source is empty
112 - decoder failed

120 - cannot encode
121 - source is empty
122 - encoder failed

130 - cannot save sync
131 - cannot insert anchor
132 - cannot update anchor
133 - cannot update db
134 - cannot add item
135 - cannot add map for item
136 - cannot replace item
137 - cannot delete item
138 - cannot delete map for item
139 - cannot add database

*/